/**
 * 
 */
package com.yidu.erp.action.wareType;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yidu.common.Pages;
import com.yidu.common.SsmMessage;
import com.yidu.erp.model.BeyondWaretype;
import com.yidu.erp.service.wareType.WareTypeService;

/**
 * 类的描述：药品种类的action
 * @author xym
 *
 * @date 2017年11月25日
 */
@Controller
@RequestMapping("wareType")
public class WareTypeAction {
	@Resource
	WareTypeService wareTypeService;

	@ResponseBody
	@RequestMapping("showAll")
	public Map<String, Object> showAll(@RequestParam Map<String, Object> map,BeyondWaretype type,Pages pages,Integer page,Integer limit){
		map.put("type", type);
		if(limit!=null&&limit>0){
		pages.setCurPage(page);
		pages.setMaxResult(limit);
		map.put("pages", pages);
		}
		return wareTypeService.showAll(map);
	}
	@RequestMapping("addOrUpdate")
	@ResponseBody
	public SsmMessage addOrUpdate(BeyondWaretype type){
		System.out.println(type.getTypeName());
		System.out.println(type.getTypeBz());
		if(type.getTypeId()!=null&&!"".equals(type.getTypeId())){
			return wareTypeService.update(type);
		}else{
			return wareTypeService.insert(type);
		}
	}
	@RequestMapping("delete")
	@ResponseBody
	public SsmMessage delete(BeyondWaretype type){
		return wareTypeService.delete(type);
	}
	@RequestMapping("findById")
	@ResponseBody
	public BeyondWaretype findById(String typeId){
		return wareTypeService.findById(typeId);
	}
}
